﻿#pragma once

#include <string>
#include <vector>
#include <cstdint>

namespace Mf4Recorder {

struct SignalBaseInfo
{
	enum class TYPE
	{
		UNKNOWN = 0,
		U8 = 1,
		S8 = 2,
		U16 = 3,
		S16 = 4,
		U32 = 5,
		S32 = 6,
		U64 = 7,
		S64 = 8,
		F32 = 9,
		F64 = 10,
	};

	struct EnumKeyValue
	{
		std::string key = "";
		int64_t value = 0;
	};

	std::string deviceName = "XCP";
	std::string name = "NULL";
	TYPE type = TYPE::UNKNOWN;
	uint64_t address = 0x00;
	double factor = 1.0;
	double offset = 0.0;
	std::string unit = "";
	std::vector<EnumKeyValue> enumKeyValue;
};

struct TimeSlice
{
	std::string label; 
	float startLabelBeforeTime = 0.0F; //unit s
	float endLabelAfterTime = 0.0F; //unit s
};

#ifdef _WIN32
extern "C" __declspec(dllexport) bool init(const std::string& configFileName, const int64_t timeStamp); //系统时间戳 unit ns
extern "C" __declspec(dllexport) void addSampleSignal(const uint32_t port, const std::vector<SignalBaseInfo>& signalBaseInfo); //port 每个线程port不能相同 且port不能为零
extern "C" __declspec(dllexport) void eventSample(const uint32_t port, const int64_t timeStamp);  //系统时间戳 unit ns //port 每个线程port不能相同 且port不能为零
extern "C" __declspec(dllexport) void addLabel(const uint32_t port, const std::vector<TimeSlice>& timeSlice, const int64_t timeStamp);   //系统时间戳 unit ns //port 每个线程port不能相同 且port不能为零
extern "C" __declspec(dllexport) void destroy(void);
#else
extern "C" __attribute((visibility("default"))) bool init(const std::string& configFileName, const int64_t timeStamp); //系统时间戳 unit ns
extern "C" __attribute((visibility("default"))) void addSampleSignal(const uint32_t port, const std::vector<SignalBaseInfo>& signalBaseInfo); //port 每个线程port不能相同 且port不能为零
extern "C" __attribute((visibility("default"))) void eventSample(const uint32_t port, const int64_t timeStamp);  //系统时间戳 unit ns //port 每个线程port不能相同 且port不能为零
extern "C" __attribute((visibility("default"))) void addLabel(const uint32_t port, const std::vector<TimeSlice>& timeSlice, const int64_t timeStamp);   //系统时间戳 unit ns //port 每个线程port不能相同 且port不能为零
extern "C" __attribute((visibility("default"))) void destroy(void);
#endif

}//namespace Mf4Recorder
